# 前面objectiveObj.py文件中有一个__init__方法，在进行实例化的时候被调用了？这是啥？
# 这是魔术方法，这些魔术方法会在特定的时间点被自动触发
# __init__外，还有其他的-------类似React中的勾子概念
from typing import Any


class Stock:
  def __init__(self, stockCode) -> None:
    print('in __init__')
    self.stockCode = stockCode
  # 回收类的时候被触发
  def __del__(self):
    print('in__del')
  def __str__(self) -> str:
    print('in__str__')
    return self.stockCode
  def __repr__(self) -> str:
    print('in__repr__')
    return self.stockCode
  def __setattr__(self, __name: str, __value: Any) -> None:
    print('in__setattr__')
    self.__dict__[__name] = __value
  def __getattr__(self, __name: str) -> Any:
    print('in__getattr__', __name)
    return self.__dict__[__name]

myStock = Stock('99999')
print(myStock)
myStock.stockCode = '8888'
myStock.stockCode1 = '8888'
print(myStock.stockCode)
print(myStock.stockCode1)
print(myStock)
